﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using LibHuman;


namespace Human
{
	
	public class frm_Thuetnct : System.Windows.Forms.Form
	{
        private AccessData acc = new AccessData();
        Language lan = new Language();
        string sql = "";		
		string thang1="",nam1="",nam2="",s_mmyy="",s_bophan="";
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.ComboBox combobphan;
        private System.Windows.Forms.TextBox txt_tyle;
        private System.Windows.Forms.ToolTip toolTip1;
		private System.ComponentModel.IContainer components;
        private DataSet ds = new DataSet();        
		int next =0,f=0,tam=0;
        decimal nc = 0;
        private System.Windows.Forms.Label label;
		private System.Windows.Forms.Label label6;
        private System.Windows.Forms.Label label7;
        private ToolStrip toolStrip3;
        private ToolStripButton toolStripButton4;
        private ToolStripLabel toolStripLabel3;
        private DataGridView dataGridView1;
        private Panel panel2;
        private Label label5;
        private TextBox txtManv;
        private Label label9;
        private LibList.List list;
        private Label label1;
        private TextBox txt_tongtnbv;
        private TextBox txt_pckhac;
        private TextBox txt_tienthue;
        private Label label3;
        private TextBox txtID;
        private Label label4;
        private TextBox txt_giacanh;
        private Label label14;
        private TextBox txt_thuong;
        private Label label13;
        private Label label11;
        private Label label8;
        private TextBox txt_trubanthan;
        private TextBox txt_trukhac;
        private TextBox txt_msthue;
        private Label label10;
        private TextBox txt_giamthue;
        private GroupBox groupBox1;
        private TextBox txt_danop;
        private Button btn_sua;
        private Button btn_boqua;
        private Button btn_them;
        private Button btn_chonbophan;
        private Button btn_thoat;
        private TextBox txt_ghichu;
        private Label gichu;
        private ComboBox cbo_hoten;
        private DataGridViewTextBoxColumn stt;
        private DataGridViewTextBoxColumn hoten;
        private DataGridViewTextBoxColumn msthue;
        private DataGridViewTextBoxColumn tongtnbv;
        private DataGridViewTextBoxColumn thuong;
        private DataGridViewTextBoxColumn tnkhac;
        private DataGridViewTextBoxColumn trubanthan;
        private DataGridViewTextBoxColumn trugiacanh;
        private DataGridViewTextBoxColumn trukhac;
        private DataGridViewTextBoxColumn tyle;
        private DataGridViewTextBoxColumn giamthue;
        private DataGridViewTextBoxColumn tienthue;
        private DataGridViewTextBoxColumn danop;
        private Label label15;		

		public frm_Thuetnct(string thang ,string nam,string s_bp)
		{
			InitializeComponent();
            lan.Read_Language_to_Xml(this.Name.ToString(), this);
            lan.Changelanguage_to_English(this.Name.ToString(), this);
			thang1=thang.Trim().PadLeft(2,'0');
			nam1=nam.Trim();
			nam2=nam1.Substring(2,2);
            s_mmyy = thang1 + nam2;
            s_bophan = s_bp;	
            if (Screen.PrimaryScreen.WorkingArea.Width>=1000)//
            {				
                this.WindowState=FormWindowState.Normal;
                this.MaximizeBox=false;
            }
            else
            {
				
                this.WindowState=FormWindowState.Maximized;
            }
		}
		
		protected override void Dispose( bool disposing )
		{
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frm_Thuetnct));
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
            this.label2 = new System.Windows.Forms.Label();
            this.combobphan = new System.Windows.Forms.ComboBox();
            this.txt_tyle = new System.Windows.Forms.TextBox();
            this.label = new System.Windows.Forms.Label();
            this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
            this.label6 = new System.Windows.Forms.Label();
            this.label7 = new System.Windows.Forms.Label();
            this.toolStrip3 = new System.Windows.Forms.ToolStrip();
            this.toolStripButton4 = new System.Windows.Forms.ToolStripButton();
            this.toolStripLabel3 = new System.Windows.Forms.ToolStripLabel();
            this.dataGridView1 = new System.Windows.Forms.DataGridView();
            this.stt = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.hoten = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.msthue = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.tongtnbv = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.thuong = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.tnkhac = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.trubanthan = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.trugiacanh = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.trukhac = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.tyle = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.giamthue = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.tienthue = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.danop = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.panel2 = new System.Windows.Forms.Panel();
            this.btn_chonbophan = new System.Windows.Forms.Button();
            this.btn_thoat = new System.Windows.Forms.Button();
            this.btn_boqua = new System.Windows.Forms.Button();
            this.btn_them = new System.Windows.Forms.Button();
            this.btn_sua = new System.Windows.Forms.Button();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.cbo_hoten = new System.Windows.Forms.ComboBox();
            this.label1 = new System.Windows.Forms.Label();
            this.txt_msthue = new System.Windows.Forms.TextBox();
            this.txt_tienthue = new System.Windows.Forms.TextBox();
            this.txt_pckhac = new System.Windows.Forms.TextBox();
            this.txt_tongtnbv = new System.Windows.Forms.TextBox();
            this.txt_trukhac = new System.Windows.Forms.TextBox();
            this.txt_giamthue = new System.Windows.Forms.TextBox();
            this.label14 = new System.Windows.Forms.Label();
            this.txt_giacanh = new System.Windows.Forms.TextBox();
            this.label10 = new System.Windows.Forms.Label();
            this.txt_ghichu = new System.Windows.Forms.TextBox();
            this.txt_danop = new System.Windows.Forms.TextBox();
            this.txt_trubanthan = new System.Windows.Forms.TextBox();
            this.txt_thuong = new System.Windows.Forms.TextBox();
            this.label5 = new System.Windows.Forms.Label();
            this.label4 = new System.Windows.Forms.Label();
            this.gichu = new System.Windows.Forms.Label();
            this.label15 = new System.Windows.Forms.Label();
            this.label13 = new System.Windows.Forms.Label();
            this.label8 = new System.Windows.Forms.Label();
            this.txtManv = new System.Windows.Forms.TextBox();
            this.label9 = new System.Windows.Forms.Label();
            this.label11 = new System.Windows.Forms.Label();
            this.label3 = new System.Windows.Forms.Label();
            this.list = new LibList.List();
            this.toolStrip3.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
            this.panel2.SuspendLayout();
            this.groupBox1.SuspendLayout();
            this.SuspendLayout();
            // 
            // label2
            // 
            this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.label2.BackColor = System.Drawing.Color.ForestGreen;
            this.label2.Font = new System.Drawing.Font("Tahoma", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label2.ForeColor = System.Drawing.Color.White;
            this.label2.Location = new System.Drawing.Point(435, 17);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(109, 24);
            this.label2.TabIndex = 1;
            this.label2.Text = "BỘ PHẬN:";
            this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // combobphan
            // 
            this.combobphan.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.combobphan.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
            this.combobphan.Enabled = false;
            this.combobphan.Font = new System.Drawing.Font("Tahoma", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.combobphan.ForeColor = System.Drawing.Color.Navy;
            this.combobphan.Location = new System.Drawing.Point(543, 17);
            this.combobphan.Name = "combobphan";
            this.combobphan.Size = new System.Drawing.Size(214, 24);
            this.combobphan.TabIndex = 20;
            this.combobphan.Validating += new System.ComponentModel.CancelEventHandler(this.combobphan_Validating);
            this.combobphan.SelectedValueChanged += new System.EventHandler(this.combobphan_SelectedValueChanged);
            this.combobphan.Validated += new System.EventHandler(this.combobphan_Validated);
            // 
            // txt_tyle
            // 
            this.txt_tyle.BackColor = System.Drawing.Color.White;
            this.txt_tyle.Enabled = false;
            this.txt_tyle.ForeColor = System.Drawing.Color.Navy;
            this.txt_tyle.Location = new System.Drawing.Point(233, 70);
            this.txt_tyle.Name = "txt_tyle";
            this.txt_tyle.Size = new System.Drawing.Size(100, 21);
            this.txt_tyle.TabIndex = 9;
            this.txt_tyle.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txt_tyle.Validated += new System.EventHandler(this.txt_tyle_Validated);
            this.txt_tyle.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_tyle_KeyDown);
            // 
            // label
            // 
            this.label.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(233)))), ((int)(((byte)(216)))));
            this.label.Dock = System.Windows.Forms.DockStyle.Fill;
            this.label.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label.Location = new System.Drawing.Point(0, 0);
            this.label.Name = "label";
            this.label.Size = new System.Drawing.Size(788, 569);
            this.label.TabIndex = 6;
            // 
            // label6
            // 
            this.label6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(233)))), ((int)(((byte)(216)))));
            this.label6.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label6.ForeColor = System.Drawing.Color.Navy;
            this.label6.Location = new System.Drawing.Point(562, 14);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(70, 13);
            this.label6.TabIndex = 25;
            this.label6.Text = "Phụ cấp khác";
            this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label7
            // 
            this.label7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(233)))), ((int)(((byte)(216)))));
            this.label7.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label7.ForeColor = System.Drawing.Color.Navy;
            this.label7.Location = new System.Drawing.Point(230, 54);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(30, 13);
            this.label7.TabIndex = 26;
            this.label7.Text = "Tỷ lệ";
            this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // toolStrip3
            // 
            this.toolStrip3.AutoSize = false;
            this.toolStrip3.BackColor = System.Drawing.Color.ForestGreen;
            this.toolStrip3.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.toolStripButton4,
            this.toolStripLabel3});
            this.toolStrip3.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow;
            this.toolStrip3.Location = new System.Drawing.Point(0, 0);
            this.toolStrip3.Name = "toolStrip3";
            this.toolStrip3.Size = new System.Drawing.Size(788, 60);
            this.toolStrip3.TabIndex = 0;
            this.toolStrip3.Text = "toolStrip3";
            // 
            // toolStripButton4
            // 
            this.toolStripButton4.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
            this.toolStripButton4.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
            this.toolStripButton4.Image = ((System.Drawing.Image)(resources.GetObject("toolStripButton4.Image")));
            this.toolStripButton4.ImageTransparentColor = System.Drawing.Color.Magenta;
            this.toolStripButton4.Name = "toolStripButton4";
            this.toolStripButton4.Size = new System.Drawing.Size(23, 57);
            this.toolStripButton4.Text = "Hướng dẫn";
            // 
            // toolStripLabel3
            // 
            this.toolStripLabel3.Font = new System.Drawing.Font("Tahoma", 15F, System.Drawing.FontStyle.Bold);
            this.toolStripLabel3.ForeColor = System.Drawing.Color.White;
            this.toolStripLabel3.Name = "toolStripLabel3";
            this.toolStripLabel3.Size = new System.Drawing.Size(273, 57);
            this.toolStripLabel3.Text = "THUẾ THU NHẬP CÁ NHÂN";
            // 
            // dataGridView1
            // 
            this.dataGridView1.AllowUserToAddRows = false;
            this.dataGridView1.AllowUserToDeleteRows = false;
            this.dataGridView1.AllowUserToOrderColumns = true;
            this.dataGridView1.BackgroundColor = System.Drawing.Color.White;
            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
            dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
            dataGridViewCellStyle1.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
            dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
            dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
            dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
            this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
            this.dataGridView1.ColumnHeadersHeight = 34;
            this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.stt,
            this.hoten,
            this.msthue,
            this.tongtnbv,
            this.thuong,
            this.tnkhac,
            this.trubanthan,
            this.trugiacanh,
            this.trukhac,
            this.tyle,
            this.giamthue,
            this.tienthue,
            this.danop});
            this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.dataGridView1.Location = new System.Drawing.Point(0, 60);
            this.dataGridView1.Name = "dataGridView1";
            this.dataGridView1.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
            this.dataGridView1.Size = new System.Drawing.Size(788, 362);
            this.dataGridView1.TabIndex = 3;
            this.dataGridView1.CellValidating += new System.Windows.Forms.DataGridViewCellValidatingEventHandler(this.dataGridView1_CellValidating);
            this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
            this.dataGridView1.CurrentCellChanged += new System.EventHandler(this.dataGridView1_CurrentCellChanged);
            // 
            // stt
            // 
            this.stt.DataPropertyName = "stt";
            this.stt.HeaderText = "STT";
            this.stt.Name = "stt";
            this.stt.Width = 40;
            // 
            // hoten
            // 
            this.hoten.DataPropertyName = "hoten";
            this.hoten.HeaderText = "Họ Tên";
            this.hoten.Name = "hoten";
            this.hoten.Width = 150;
            // 
            // msthue
            // 
            this.msthue.DataPropertyName = "msthue";
            this.msthue.HeaderText = "Mã số thuế";
            this.msthue.Name = "msthue";
            // 
            // tongtnbv
            // 
            this.tongtnbv.DataPropertyName = "tongtnbv";
            this.tongtnbv.HeaderText = "Tổng lương bệnh viện";
            this.tongtnbv.Name = "tongtnbv";
            // 
            // thuong
            // 
            this.thuong.DataPropertyName = "thuong";
            this.thuong.HeaderText = "Tiền thưởng";
            this.thuong.Name = "thuong";
            // 
            // tnkhac
            // 
            this.tnkhac.DataPropertyName = "tnkhac";
            this.tnkhac.HeaderText = "Thu nhập khác";
            this.tnkhac.Name = "tnkhac";
            // 
            // trubanthan
            // 
            this.trubanthan.DataPropertyName = "t_banthan";
            this.trubanthan.HeaderText = "Trừ bản thân";
            this.trubanthan.Name = "trubanthan";
            // 
            // trugiacanh
            // 
            this.trugiacanh.DataPropertyName = "t_giacanh";
            this.trugiacanh.HeaderText = "Trừ gia cảnh";
            this.trugiacanh.Name = "trugiacanh";
            // 
            // trukhac
            // 
            this.trukhac.DataPropertyName = "t_khac";
            this.trukhac.HeaderText = "Trừ khác";
            this.trukhac.Name = "trukhac";
            // 
            // tyle
            // 
            this.tyle.DataPropertyName = "tyle";
            this.tyle.HeaderText = "Tỷ lệ";
            this.tyle.Name = "tyle";
            this.tyle.Width = 40;
            // 
            // giamthue
            // 
            this.giamthue.DataPropertyName = "giamthue";
            this.giamthue.HeaderText = "Giảm thuế";
            this.giamthue.Name = "giamthue";
            this.giamthue.Width = 40;
            // 
            // tienthue
            // 
            this.tienthue.DataPropertyName = "t_thuetncn";
            this.tienthue.HeaderText = "Tiền thuế";
            this.tienthue.Name = "tienthue";
            // 
            // danop
            // 
            this.danop.DataPropertyName = "danop";
            this.danop.HeaderText = "Đã nộp";
            this.danop.Name = "danop";
            // 
            // panel2
            // 
            this.panel2.BackColor = System.Drawing.SystemColors.Control;
            this.panel2.Controls.Add(this.btn_chonbophan);
            this.panel2.Controls.Add(this.btn_thoat);
            this.panel2.Controls.Add(this.btn_boqua);
            this.panel2.Controls.Add(this.btn_them);
            this.panel2.Controls.Add(this.btn_sua);
            this.panel2.Controls.Add(this.groupBox1);
            this.panel2.Controls.Add(this.list);
            this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.panel2.Location = new System.Drawing.Point(0, 422);
            this.panel2.Name = "panel2";
            this.panel2.Size = new System.Drawing.Size(788, 147);
            this.panel2.TabIndex = 4;
            // 
            // btn_chonbophan
            // 
            this.btn_chonbophan.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btn_chonbophan.Image = global::Human.Properties.Resources.chonkhoa;
            this.btn_chonbophan.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btn_chonbophan.Location = new System.Drawing.Point(412, 116);
            this.btn_chonbophan.Name = "btn_chonbophan";
            this.btn_chonbophan.Size = new System.Drawing.Size(105, 28);
            this.btn_chonbophan.TabIndex = 1;
            this.btn_chonbophan.Text = "Bộ phận khác";
            this.btn_chonbophan.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.btn_chonbophan.UseVisualStyleBackColor = true;
            this.btn_chonbophan.Click += new System.EventHandler(this.btn_chonbophan_Click);
            // 
            // btn_thoat
            // 
            this.btn_thoat.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btn_thoat.Image = global::Human.Properties.Resources.close_r;
            this.btn_thoat.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btn_thoat.Location = new System.Drawing.Point(519, 116);
            this.btn_thoat.Name = "btn_thoat";
            this.btn_thoat.Size = new System.Drawing.Size(60, 28);
            this.btn_thoat.TabIndex = 1;
            this.btn_thoat.Text = "Thoát";
            this.btn_thoat.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.btn_thoat.UseVisualStyleBackColor = true;
            this.btn_thoat.Click += new System.EventHandler(this.btn_thoat_Click);
            // 
            // btn_boqua
            // 
            this.btn_boqua.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btn_boqua.Image = global::Human.Properties.Resources.t_boqua11;
            this.btn_boqua.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btn_boqua.Location = new System.Drawing.Point(336, 116);
            this.btn_boqua.Name = "btn_boqua";
            this.btn_boqua.Size = new System.Drawing.Size(70, 28);
            this.btn_boqua.TabIndex = 1;
            this.btn_boqua.Text = "Bỏ qua";
            this.btn_boqua.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.btn_boqua.UseVisualStyleBackColor = true;
            this.btn_boqua.Click += new System.EventHandler(this.btn_boqua_Click);
            // 
            // btn_them
            // 
            this.btn_them.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btn_them.Image = global::Human.Properties.Resources.add;
            this.btn_them.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btn_them.Location = new System.Drawing.Point(196, 116);
            this.btn_them.Name = "btn_them";
            this.btn_them.Size = new System.Drawing.Size(60, 28);
            this.btn_them.TabIndex = 1;
            this.btn_them.Text = "Thêm";
            this.btn_them.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.btn_them.UseVisualStyleBackColor = true;
            this.btn_them.Click += new System.EventHandler(this.btn_them_Click);
            // 
            // btn_sua
            // 
            this.btn_sua.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btn_sua.Image = global::Human.Properties.Resources.quick_edit;
            this.btn_sua.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
            this.btn_sua.Location = new System.Drawing.Point(270, 116);
            this.btn_sua.Name = "btn_sua";
            this.btn_sua.Size = new System.Drawing.Size(60, 28);
            this.btn_sua.TabIndex = 1;
            this.btn_sua.Text = "Sửa";
            this.btn_sua.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            this.btn_sua.UseVisualStyleBackColor = true;
            this.btn_sua.Click += new System.EventHandler(this.btn_sua_Click);
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.cbo_hoten);
            this.groupBox1.Controls.Add(this.txt_tyle);
            this.groupBox1.Controls.Add(this.label1);
            this.groupBox1.Controls.Add(this.txt_msthue);
            this.groupBox1.Controls.Add(this.txt_tienthue);
            this.groupBox1.Controls.Add(this.txt_pckhac);
            this.groupBox1.Controls.Add(this.txt_tongtnbv);
            this.groupBox1.Controls.Add(this.txt_trukhac);
            this.groupBox1.Controls.Add(this.txt_giamthue);
            this.groupBox1.Controls.Add(this.label14);
            this.groupBox1.Controls.Add(this.txt_giacanh);
            this.groupBox1.Controls.Add(this.label10);
            this.groupBox1.Controls.Add(this.txt_ghichu);
            this.groupBox1.Controls.Add(this.txt_danop);
            this.groupBox1.Controls.Add(this.txt_trubanthan);
            this.groupBox1.Controls.Add(this.txt_thuong);
            this.groupBox1.Controls.Add(this.label6);
            this.groupBox1.Controls.Add(this.label5);
            this.groupBox1.Controls.Add(this.label4);
            this.groupBox1.Controls.Add(this.gichu);
            this.groupBox1.Controls.Add(this.label15);
            this.groupBox1.Controls.Add(this.label13);
            this.groupBox1.Controls.Add(this.label8);
            this.groupBox1.Controls.Add(this.txtManv);
            this.groupBox1.Controls.Add(this.label9);
            this.groupBox1.Controls.Add(this.label7);
            this.groupBox1.Controls.Add(this.label11);
            this.groupBox1.Controls.Add(this.label3);
            this.groupBox1.Location = new System.Drawing.Point(3, 9);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(791, 101);
            this.groupBox1.TabIndex = 35;
            this.groupBox1.TabStop = false;
            // 
            // cbo_hoten
            // 
            this.cbo_hoten.ForeColor = System.Drawing.Color.DarkBlue;
            this.cbo_hoten.FormattingEnabled = true;
            this.cbo_hoten.Location = new System.Drawing.Point(60, 30);
            this.cbo_hoten.Name = "cbo_hoten";
            this.cbo_hoten.Size = new System.Drawing.Size(161, 21);
            this.cbo_hoten.TabIndex = 1;
            this.cbo_hoten.SelectedValueChanged += new System.EventHandler(this.cbo_hoten_SelectedValueChanged);
            this.cbo_hoten.KeyDown += new System.Windows.Forms.KeyEventHandler(this.cbo_hoten_KeyDown);
            // 
            // label1
            // 
            this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.label1.Location = new System.Drawing.Point(358, 14);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(65, 13);
            this.label1.TabIndex = 16;
            this.label1.Text = "Lương chính";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // txt_msthue
            // 
            this.txt_msthue.BackColor = System.Drawing.Color.White;
            this.txt_msthue.Enabled = false;
            this.txt_msthue.ForeColor = System.Drawing.Color.Navy;
            this.txt_msthue.Location = new System.Drawing.Point(233, 30);
            this.txt_msthue.Name = "txt_msthue";
            this.txt_msthue.Size = new System.Drawing.Size(100, 21);
            this.txt_msthue.TabIndex = 2;
            this.txt_msthue.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            // 
            // txt_tienthue
            // 
            this.txt_tienthue.BackColor = System.Drawing.Color.White;
            this.txt_tienthue.Enabled = false;
            this.txt_tienthue.ForeColor = System.Drawing.Color.Navy;
            this.txt_tienthue.Location = new System.Drawing.Point(430, 70);
            this.txt_tienthue.Name = "txt_tienthue";
            this.txt_tienthue.Size = new System.Drawing.Size(85, 21);
            this.txt_tienthue.TabIndex = 11;
            this.txt_tienthue.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txt_tienthue.Validated += new System.EventHandler(this.txt_tienthue_Validated);
            this.txt_tienthue.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_tienthue_KeyDown);
            // 
            // txt_pckhac
            // 
            this.txt_pckhac.BackColor = System.Drawing.Color.White;
            this.txt_pckhac.Enabled = false;
            this.txt_pckhac.ForeColor = System.Drawing.Color.Navy;
            this.txt_pckhac.Location = new System.Drawing.Point(521, 30);
            this.txt_pckhac.Name = "txt_pckhac";
            this.txt_pckhac.Size = new System.Drawing.Size(85, 21);
            this.txt_pckhac.TabIndex = 5;
            this.txt_pckhac.Text = "0";
            this.txt_pckhac.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txt_pckhac.Validated += new System.EventHandler(this.txt_pckhac_Validated);
            this.txt_pckhac.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_pckhac_KeyDown);
            // 
            // txt_tongtnbv
            // 
            this.txt_tongtnbv.BackColor = System.Drawing.Color.White;
            this.txt_tongtnbv.Enabled = false;
            this.txt_tongtnbv.ForeColor = System.Drawing.Color.Navy;
            this.txt_tongtnbv.Location = new System.Drawing.Point(339, 30);
            this.txt_tongtnbv.Name = "txt_tongtnbv";
            this.txt_tongtnbv.Size = new System.Drawing.Size(85, 21);
            this.txt_tongtnbv.TabIndex = 3;
            this.txt_tongtnbv.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txt_tongtnbv.Validated += new System.EventHandler(this.txt_tongtnbv_Validated);
            this.txt_tongtnbv.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_tongtnbv_KeyDown);
            // 
            // txt_trukhac
            // 
            this.txt_trukhac.BackColor = System.Drawing.Color.White;
            this.txt_trukhac.Enabled = false;
            this.txt_trukhac.ForeColor = System.Drawing.Color.Navy;
            this.txt_trukhac.Location = new System.Drawing.Point(121, 70);
            this.txt_trukhac.Name = "txt_trukhac";
            this.txt_trukhac.Size = new System.Drawing.Size(100, 21);
            this.txt_trukhac.TabIndex = 8;
            this.txt_trukhac.Text = "0";
            this.txt_trukhac.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txt_trukhac.Validated += new System.EventHandler(this.txt_trukhac_Validated);
            this.txt_trukhac.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_trukhac_KeyDown);
            // 
            // txt_giamthue
            // 
            this.txt_giamthue.BackColor = System.Drawing.Color.White;
            this.txt_giamthue.Enabled = false;
            this.txt_giamthue.ForeColor = System.Drawing.Color.Navy;
            this.txt_giamthue.Location = new System.Drawing.Point(339, 70);
            this.txt_giamthue.Name = "txt_giamthue";
            this.txt_giamthue.Size = new System.Drawing.Size(85, 21);
            this.txt_giamthue.TabIndex = 10;
            this.txt_giamthue.Text = "0";
            this.txt_giamthue.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txt_giamthue.Validated += new System.EventHandler(this.txt_giamthue_Validated);
            this.txt_giamthue.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_giamthue_KeyDown);
            // 
            // label14
            // 
            this.label14.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.label14.Location = new System.Drawing.Point(462, 14);
            this.label14.Name = "label14";
            this.label14.Size = new System.Drawing.Size(44, 13);
            this.label14.TabIndex = 17;
            this.label14.Text = "Thưởng";
            this.label14.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // txt_giacanh
            // 
            this.txt_giacanh.BackColor = System.Drawing.Color.White;
            this.txt_giacanh.Enabled = false;
            this.txt_giacanh.ForeColor = System.Drawing.Color.Navy;
            this.txt_giacanh.Location = new System.Drawing.Point(10, 70);
            this.txt_giacanh.Name = "txt_giacanh";
            this.txt_giacanh.Size = new System.Drawing.Size(100, 21);
            this.txt_giacanh.TabIndex = 7;
            this.txt_giacanh.Text = "0";
            this.txt_giacanh.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txt_giacanh.Validated += new System.EventHandler(this.txt_giacanh_Validated);
            this.txt_giacanh.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_giacanh_KeyDown);
            // 
            // label10
            // 
            this.label10.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(233)))), ((int)(((byte)(216)))));
            this.label10.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label10.ForeColor = System.Drawing.Color.Navy;
            this.label10.Location = new System.Drawing.Point(336, 54);
            this.label10.Name = "label10";
            this.label10.Size = new System.Drawing.Size(74, 13);
            this.label10.TabIndex = 25;
            this.label10.Text = "Gỉam thuế(%)";
            this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // txt_ghichu
            // 
            this.txt_ghichu.BackColor = System.Drawing.Color.White;
            this.txt_ghichu.Enabled = false;
            this.txt_ghichu.ForeColor = System.Drawing.Color.Navy;
            this.txt_ghichu.Location = new System.Drawing.Point(612, 70);
            this.txt_ghichu.Name = "txt_ghichu";
            this.txt_ghichu.Size = new System.Drawing.Size(173, 21);
            this.txt_ghichu.TabIndex = 13;
            this.txt_ghichu.Validated += new System.EventHandler(this.txt_ghichu_Validated);
            this.txt_ghichu.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_ghichu_KeyDown);
            // 
            // txt_danop
            // 
            this.txt_danop.BackColor = System.Drawing.Color.White;
            this.txt_danop.Enabled = false;
            this.txt_danop.ForeColor = System.Drawing.Color.Navy;
            this.txt_danop.Location = new System.Drawing.Point(521, 70);
            this.txt_danop.Name = "txt_danop";
            this.txt_danop.Size = new System.Drawing.Size(85, 21);
            this.txt_danop.TabIndex = 12;
            this.txt_danop.Validated += new System.EventHandler(this.txt_danop_Validated);
            this.txt_danop.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_danop_KeyDown);
            // 
            // txt_trubanthan
            // 
            this.txt_trubanthan.BackColor = System.Drawing.Color.White;
            this.txt_trubanthan.Enabled = false;
            this.txt_trubanthan.ForeColor = System.Drawing.Color.Navy;
            this.txt_trubanthan.Location = new System.Drawing.Point(612, 30);
            this.txt_trubanthan.Name = "txt_trubanthan";
            this.txt_trubanthan.Size = new System.Drawing.Size(85, 21);
            this.txt_trubanthan.TabIndex = 6;
            this.txt_trubanthan.Text = "4000000";
            this.txt_trubanthan.Validated += new System.EventHandler(this.txt_trubanthan_Validated);
            this.txt_trubanthan.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_trubanthan_KeyDown);
            // 
            // txt_thuong
            // 
            this.txt_thuong.BackColor = System.Drawing.Color.White;
            this.txt_thuong.Enabled = false;
            this.txt_thuong.ForeColor = System.Drawing.Color.Navy;
            this.txt_thuong.Location = new System.Drawing.Point(430, 30);
            this.txt_thuong.Name = "txt_thuong";
            this.txt_thuong.Size = new System.Drawing.Size(85, 21);
            this.txt_thuong.TabIndex = 4;
            this.txt_thuong.Validated += new System.EventHandler(this.txt_thuong_Validated);
            this.txt_thuong.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txt_thuong_KeyDown);
            // 
            // label5
            // 
            this.label5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.label5.Location = new System.Drawing.Point(6, 14);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(37, 13);
            this.label5.TabIndex = 17;
            this.label5.Text = "Mã NV";
            this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label4
            // 
            this.label4.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(233)))), ((int)(((byte)(216)))));
            this.label4.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label4.ForeColor = System.Drawing.Color.Navy;
            this.label4.Location = new System.Drawing.Point(7, 54);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(67, 13);
            this.label4.TabIndex = 25;
            this.label4.Text = "Trừ gia cảnh";
            this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // gichu
            // 
            this.gichu.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.gichu.Location = new System.Drawing.Point(609, 54);
            this.gichu.Name = "gichu";
            this.gichu.Size = new System.Drawing.Size(42, 13);
            this.gichu.TabIndex = 32;
            this.gichu.Text = "Ghi chú";
            this.gichu.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label15
            // 
            this.label15.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.label15.Location = new System.Drawing.Point(518, 54);
            this.label15.Name = "label15";
            this.label15.Size = new System.Drawing.Size(42, 13);
            this.label15.TabIndex = 32;
            this.label15.Text = "Đã nộp";
            this.label15.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label13
            // 
            this.label13.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.label13.Location = new System.Drawing.Point(665, 14);
            this.label13.Name = "label13";
            this.label13.Size = new System.Drawing.Size(70, 13);
            this.label13.TabIndex = 32;
            this.label13.Text = "Trừ bản thân";
            this.label13.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label8
            // 
            this.label8.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(233)))), ((int)(((byte)(216)))));
            this.label8.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label8.ForeColor = System.Drawing.Color.Navy;
            this.label8.Location = new System.Drawing.Point(118, 54);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(49, 13);
            this.label8.TabIndex = 25;
            this.label8.Text = "Trừ khác";
            this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // txtManv
            // 
            this.txtManv.BackColor = System.Drawing.Color.White;
            this.txtManv.Enabled = false;
            this.txtManv.ForeColor = System.Drawing.Color.Navy;
            this.txtManv.Location = new System.Drawing.Point(9, 30);
            this.txtManv.Name = "txtManv";
            this.txtManv.Size = new System.Drawing.Size(45, 21);
            this.txtManv.TabIndex = 0;
            // 
            // label9
            // 
            this.label9.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(160)))));
            this.label9.Location = new System.Drawing.Point(65, 14);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(39, 13);
            this.label9.TabIndex = 32;
            this.label9.Text = "Họ tên";
            this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label11
            // 
            this.label11.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(233)))), ((int)(((byte)(216)))));
            this.label11.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label11.ForeColor = System.Drawing.Color.Navy;
            this.label11.Location = new System.Drawing.Point(240, 14);
            this.label11.Name = "label11";
            this.label11.Size = new System.Drawing.Size(27, 13);
            this.label11.TabIndex = 26;
            this.label11.Text = "MST";
            this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // label3
            // 
            this.label3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(236)))), ((int)(((byte)(233)))), ((int)(((byte)(216)))));
            this.label3.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.label3.ForeColor = System.Drawing.Color.Navy;
            this.label3.Location = new System.Drawing.Point(427, 54);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(52, 13);
            this.label3.TabIndex = 26;
            this.label3.Text = "Tiền thuế";
            this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
            // 
            // list
            // 
            this.list.ColumnCount = 0;
            this.list.Location = new System.Drawing.Point(0, 0);
            this.list.MatchBufferTimeOut = 1000;
            this.list.MatchEntryStyle = AsYetUnnamed.MatchEntryStyle.FirstLetterInsensitive;
            this.list.Name = "list";
            this.list.Size = new System.Drawing.Size(0, 4);
            this.list.TabIndex = 34;
            this.list.TextIndex = -1;
            this.list.TextMember = null;
            this.list.ValueIndex = -1;
            this.list.Visible = false;
            // 
            // frm_Thuetnct
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
            this.ClientSize = new System.Drawing.Size(788, 569);
            this.Controls.Add(this.dataGridView1);
            this.Controls.Add(this.panel2);
            this.Controls.Add(this.combobphan);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.toolStrip3);
            this.Controls.Add(this.label);
            this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.ForeColor = System.Drawing.Color.Navy;
            this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
            this.Name = "frm_Thuetnct";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "Cập nhật các khoản thu nhập của nhân viên dùng để tính thuế thu nhập";
            this.Load += new System.EventHandler(this.frm_Thuetnct_Load);
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frm_Thuetnct_FormClosing);
            this.toolStrip3.ResumeLayout(false);
            this.toolStrip3.PerformLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
            this.panel2.ResumeLayout(false);
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.ResumeLayout(false);

		}
		#endregion

		private void buttonclose_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
        private void ena_ctrl(bool ena)
        {
            txtManv.Enabled = !ena;
            cbo_hoten.Enabled = ena;
            txt_msthue.Enabled = !ena;
            txt_tongtnbv.Enabled = !ena;
            txt_thuong.Enabled = ena;
            txt_pckhac.Enabled = ena;
            txt_trubanthan.Enabled = ena;
            txt_giacanh.Enabled=ena;
            txt_trukhac.Enabled=ena;
            txt_tyle.Enabled=ena;
            txt_giamthue.Enabled=ena;
            txt_tienthue.Enabled=ena;
            txt_danop.Enabled = ena;
            txt_ghichu.Enabled = ena;
        }
        private void refesh()
        {
            txt_thuong.Text = "";
            txt_pckhac.Text = "";
            txt_trubanthan.Text = "";
            txt_giacanh.Text = "";
            txt_trukhac.Text = "";
            txt_tyle.Text = "";
            txt_giamthue.Text = "";
            txt_tienthue.Text = "";
            txt_danop.Text = "";
            txt_ghichu.Text = "";
        }
        private void load_rong()
        {
            txtManv.Text = "";
            cbo_hoten.SelectedIndex = -1;
            txt_msthue.Text = "";
            txt_tongtnbv.Text = "";
            txt_thuong.Text = "";
            txt_pckhac.Text = "";
            txt_trubanthan.Text = "";
            txt_giacanh.Text = "";
            txt_trukhac.Text = "";
            txt_tyle.Text = "";
            txt_giamthue.Text = "";
            txt_tienthue.Text = "";
            txt_danop.Text = "";
            txt_ghichu.Text = "";
        }
        private void Filt_hoten(string ten)
        {
            CurrencyManager cm = (CurrencyManager)BindingContext[list.DataSource];
            DataView dv = (DataView)cm.List;
            dv.RowFilter = "hoten LIKE '%" + ten.Trim() + "%'";
        }
        private void load_data()
        {
            int i=0;
            sql = " select '' as stt,nv.manv, trim(nv.ho)||' '||trim(nv.ten) as hoten,l.msthue,bp.tenbp,tn.mmyy,nv.loaihd";
            sql += " ,((t_luong+t_pcvuotkhung+t_pcchucvu+t_pctrachnhiem+t_pclaynhiem+t_pcudnghe+t_pcbdhv+t_ngoaigio+t_pctrucchuyenmon+t_pcabc+t_pcphauthuat+t_pcthuthuat+ t_pckhuvuc+t_pcuudai+t_thkhac)";
            sql += " - (t_trunghi+t_bhxh +t_bhyt+t_bhtn+t_kpcd )) as tongtnbv,th.thuong as thuong,th.tnkhac as tnkhac,th.giamthue as giamthue,th.danop as danop";
            sql += " ,th.t_banthan ,th.t_giacanh ,th.tyle,th.t_thuetncn ,th.loaitn as loaitn,th.trukhac,'' as ghichu";
            sql += " from " + acc.user + ".nv_" + s_mmyy + " nv left join " + acc.user + ".bophan bp on nv.madv=bp.madv";
            sql += " left join " + acc.user + ".thunhap_" + s_mmyy + " tn on nv.manv=tn.manv";
            sql += " left join "+acc.user+".llnv l on nv.manv=l.manv";
            sql += " left join "+acc.user+".mahd mh on nv.loaihd=mh.mahd";
            sql += " left join "+ acc.user+".thnh_"+s_mmyy+" th on nv.manv=th.manv";
            sql += " where tn.madv='"+s_bophan.Trim()+"'";
            ds = acc.get_data(sql);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                i++;
                dr["stt"] = i.ToString();
            }
            dataGridView1.DataSource = ds.Tables[0];
            
            load_hoten();
        }
        private void load_hoten()
        {
            try
            {
                string sql = "select a.manv,b.ho||' '||b.ten as hoten ";
                sql += " from " + acc.user + ".nn  a, " + acc.user + ".nv  b";
                sql += " where a.madv='" + s_bophan + "' and a.manv=b.manv and a.mmyy=b.mmyy and b.mmyy='" + s_mmyy + "'";
                sql += " order by a.manv,b.ten,b.ho ";
                DataSet dss = new DataSet();
                dss = acc.get_data(sql);
                cbo_hoten.DisplayMember = "hoten";
                cbo_hoten.ValueMember = "manv";
                cbo_hoten.DataSource = dss.Tables[0];
                txtManv.Text = cbo_hoten.SelectedValue.ToString();
                cbo_hoten.Focus();
            }
            catch { }
        }
        private void frm_Thuetnct_Load(object sender, EventArgs e)
        {
            load_bophan();
            load_data();
        }
        private void load_bophan()
        {
            DataTable dt = acc.get_data(" select madv,tenbp from "+acc.user+".bophan order by madv").Tables[0];
            combobphan.DisplayMember = "tenbp";
            combobphan.ValueMember = "madv";
            combobphan.DataSource = dt;
            combobphan.SelectedIndex = -1;
        }

        private void cmdThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                DataRowView drv = (DataRowView)(dataGridView1.CurrentRow.DataBoundItem);
                cbo_hoten.SelectedValue = drv["manv"].ToString().Trim();
                txt_msthue.Text = drv["msthue"].ToString();
                txt_tongtnbv.Text = drv["tongtnbv"].ToString();
                txt_thuong.Text = drv["thuong"].ToString();
                txt_pckhac.Text = drv["tnkhac"].ToString();
                txt_trubanthan.Text = drv["t_banthan"].ToString();
                txt_giacanh.Text = drv["t_giacanh"].ToString();
                txt_tyle.Text = drv["tyle"].ToString();
                txt_giamthue.Text = drv["giamthue"].ToString();
                txt_tienthue.Text = drv["t_thuetncn"].ToString();
                txt_danop.Text = drv["danop"].ToString();
                txt_trukhac.Text = drv["trukhac"].ToString();
            }
            catch(Exception ex)
            {
                ex.ToString();
            }
            cbo_hoten.Focus();

        }
        private void save()
        {
            ds.AcceptChanges();

                acc.upd_thuetncn(txtManv.Text.Trim(), s_mmyy, s_bophan, decimal.Parse(txt_tongtnbv.Text), decimal.Parse(txt_thuong.Text), decimal.Parse(txt_pckhac.Text)
            , decimal.Parse(txt_trubanthan.Text), decimal.Parse(txt_giacanh.Text), decimal.Parse(txt_trukhac.Text)
            , decimal.Parse(txt_tyle.Text), decimal.Parse(txt_giamthue.Text), decimal.Parse(txt_tienthue.Text)
            , decimal.Parse(txt_danop.Text), txt_ghichu.Text);
            
        }
        
       
        private bool ktra_textbox(TextBox t)
        {
            if (t.Text != "")
            {
                if (!acc.IsNumeric(t.Text.Trim()))
                {
                    MessageBox.Show("Dữ liệu không hợp lệ","Thông báo",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                    t.Focus();
                    return false;
                }
            }
            else
            {
                t.Text = "0";
            }
            return true;
        }

        decimal t_tyle = 0,tongtn=0;
        private decimal tinh_tyle(string manv)
        {
            decimal t_tongtnbv = 0, t_thuong = 0, t_pckhac = 0, tru_banthan = 0, tru_giacanh = 0,  tru_giamthue = 0, t_danop = 0, t_trukhac = 0;
            t_tongtnbv = decimal.Parse((txt_tongtnbv.Text!="" ? txt_tongtnbv.Text.Trim():"0"));
            t_thuong = decimal.Parse(txt_thuong.Text!="" ?  txt_thuong.Text.Trim():"0");
            t_pckhac = decimal.Parse(txt_pckhac.Text!="" ? txt_pckhac.Text.Trim():"0");
            tru_banthan = decimal.Parse(txt_trubanthan.Text!="" ? txt_trubanthan.Text.Trim():"0");
            tru_giacanh = decimal.Parse(txt_giacanh.Text!="" ? txt_giacanh.Text.Trim():"0");
            t_trukhac = decimal.Parse(txt_trukhac.Text!="" ? txt_trukhac.Text.Trim():"0");
            tongtn = (t_tongtnbv + t_thuong + t_pckhac) - (tru_banthan + tru_giacanh + t_trukhac);
            if (tongtn >= 0)
            {
                DataSet dstl = new DataSet();
                dstl = acc.get_data(" select * from " + acc.user+ ".tvn order by id");
                 
                foreach (DataRow dr in dstl.Tables[0].Rows)
                {
                    if (decimal.Parse(dr["gh_duoi"].ToString()) <= tongtn && tongtn < decimal.Parse(dr["gh_tren"].ToString()))
                    {
                        t_tyle = decimal.Parse(dr["tyle_thue"].ToString());
                    }
                }
            }
            else
            {
                return 0;
            }
            return t_tyle;

        }
        # region cac su kien ctrol
        private void txt_tongtnbv_Validated(object sender, EventArgs e)
        {
            ktra_textbox(txt_tongtnbv); return;
            string ma_nv = txtManv.Text.Trim();
            DataRow[] dr = ds.Tables[0].Select(" manv='"+ma_nv+"'");
            if (dr.Length>0)
            {
                if (txt_tongtnbv.Text != "")
                {
                    dr[0]["t_tongtnbv"] = txt_tongtnbv.Text.Trim();
                }
            }

        }

        private void txt_thuong_Validated(object sender, EventArgs e)
        {
            if(!ktra_textbox(txt_thuong)) return;
            string ma_nv = txtManv.Text.Trim();
            DataRow[] dr = ds.Tables[0].Select(" manv='" + ma_nv + "'");
            if (dr.Length > 0)
            {
                if (txt_thuong.Text != "")
                {
                    dr[0]["thuong"] = txt_thuong.Text.Trim();
                }
            }
        }

        private void txt_pckhac_Validated(object sender, EventArgs e)
        {
            if(!ktra_textbox(txt_pckhac)) return;
            string ma_nv = txtManv.Text.Trim();
            DataRow[] dr = ds.Tables[0].Select(" manv='" + ma_nv + "'");
            if (dr.Length > 0)
            {
                if (txt_pckhac.Text != "")
                {
                    dr[0]["tnkhac"] = txt_pckhac.Text.Trim();
                }
            }
        }
        private void txt_trubanthan_Validated(object sender, EventArgs e)
        {
            if(!ktra_textbox(txt_trubanthan)) return;
            string ma_nv = txtManv.Text.Trim();
            DataRow[] dr = ds.Tables[0].Select(" manv='" + ma_nv + "'");
            if (dr.Length > 0)
            {
                if (txt_trubanthan.Text != "")
                {
                    dr[0]["t_banthan"] = txt_trubanthan.Text.Trim();
                }
            }
        }

        private void txt_giacanh_Validated(object sender, EventArgs e)
        {
            if(!ktra_textbox(txt_giacanh)) return;
            string ma_nv = txtManv.Text.Trim();
            DataRow[] dr = ds.Tables[0].Select(" manv='" + ma_nv + "'");
            if (dr.Length > 0)
            {
                if (txt_giacanh.Text != "")
                {
                    dr[0]["t_giacanh"] = txt_giacanh.Text.Trim();
                }
            }
        }
        private void txt_trukhac_Validated(object sender, EventArgs e)
        {
            if (!ktra_textbox(txt_trukhac)) return;
            string ma_nv = txtManv.Text.Trim();
            DataRow[] dr = ds.Tables[0].Select(" manv='" + ma_nv + "'");
            if (dr.Length > 0)
            {
                if (txt_trukhac.Text != "")
                {
                    dr[0]["trukhac"] = txt_trukhac.Text.Trim();
                }
            }
        }
        private void txt_tyle_Validated(object sender, EventArgs e)
        {
            string ma_nv = txtManv.Text.Trim();
            tinh_tyle(ma_nv);
            txt_tyle.Text = t_tyle.ToString();
            DataRow[] dr = ds.Tables[0].Select(" manv='" + ma_nv + "'");
            if (dr.Length > 0)
            {
                if (txt_tyle.Text != "")
                {
                    dr[0]["tyle"] = txt_tyle.Text.Trim();
                }
            }
        }
        private void txt_giamthue_Validated(object sender, EventArgs e)
        {
            if(!ktra_textbox(txt_giamthue)) return;
            string ma_nv = txtManv.Text.Trim();
            DataRow[] dr = ds.Tables[0].Select(" manv='" + ma_nv + "'");
            if (dr.Length > 0)
            {
                if (txt_giamthue.Text != "")
                {
                    dr[0]["giamthue"] = txt_giamthue.Text.Trim();
                }
            }
            decimal tienphainop=t_tyle * tongtn / 100;
            if (txt_giamthue.Text.Trim() != "0")
            {
                tienphainop = tienphainop-( tienphainop * decimal.Parse(txt_giamthue.Text.Trim()) / 100);
            }
            txt_tienthue.Text = tienphainop.ToString("###,###");
        }

        private void txt_tienthue_Validated(object sender, EventArgs e)
        {
           // ktra_textbox(txt_tienthue); return;

            string ma_nv = txtManv.Text.Trim();
            DataRow[] dr = ds.Tables[0].Select(" manv='" + ma_nv + "'");
            if (dr.Length > 0)
            {
                if (txt_tienthue.Text != "")
                {
                    dr[0]["t_thuetncn"] = txt_tienthue.Text.Trim();
                }
                else
                {
                    txt_tienthue.Text = "0";
                }
            }
        }

        private void txt_danop_Validated(object sender, EventArgs e)
        {
            if(!ktra_textbox(txt_danop)) return;
            string ma_nv = txtManv.Text.Trim();
            DataRow[] dr = ds.Tables[0].Select(" manv='" + ma_nv + "'");
            if (dr.Length > 0)
            {
                if (txt_danop.Text != "")
                {
                    dr[0]["danop"] = txt_danop.Text.Trim();
                }
            }
        }
        private void txt_ghichu_Validated(object sender, EventArgs e)
        {
            string ma_nv = txtManv.Text.Trim();
            DataRow[] dr = ds.Tables[0].Select(" manv='" + ma_nv + "'");
            if (dr.Length > 0)
            {
                if (txt_ghichu.Text != "")
                {
                    dr[0]["ghichu"] = txt_ghichu.Text.Trim();
                }
            }
        }
        private void txt_tongtnbv_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                SendKeys.Send("{Tab}");
        }

        private void txt_thuong_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                SendKeys.Send("{Tab}");
        }

        private void txt_pckhac_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                SendKeys.Send("{Tab}");
        }

        private void txt_trubanthan_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                SendKeys.Send("{Tab}");
        }

        private void txt_giacanh_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                SendKeys.Send("{Tab}");
        }

        private void txt_trukhac_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                SendKeys.Send("{Tab}");
        }

        private void txt_tyle_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                SendKeys.Send("{Tab}");
        }

        private void txt_giamthue_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                SendKeys.Send("{Tab}");
        }

        private void txt_tienthue_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                SendKeys.Send("{Tab}");
        }

        private void txt_danop_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                SendKeys.Send("{Tab}");
                //txt_ghichu.Focus();
        }

        private void txt_ghichu_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                btn_them.Focus();
        }
        #endregion


        private void btn_sua_Click(object sender, EventArgs e)
        {
            ena_ctrl(true);

            txt_thuong.Focus();
        }

        private void btn_them_Click(object sender, EventArgs e)
        {
                save();
            refesh();
            this.BindingContext[ds.Tables[0]].Position += 1;
            this.Update();
            SendKeys.Send("{Tab}");
            cbo_hoten.Focus();
        }

        
        private void btn_chonbophan_Click(object sender, EventArgs e)
        {
            if (ds.HasChanges())
            {
                DialogResult = MessageBox.Show("Dữ liệu đã bị thay đổi. Bạn có muốn lưu lại không?",AccessData.Msg, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                switch (DialogResult)
                {
                    case DialogResult.Cancel:
                        return;
                    case DialogResult.No:
                        break;
                    case DialogResult.Yes:
                        btn_them.PerformClick();
                        break;
                }
            }
            combobphan.Enabled = true;
            SendKeys.Send("{F4}");
            combobphan.Focus();
        }

        private void combobphan_Validated(object sender, EventArgs e)
        {

        }

        private void combobphan_Validating(object sender, CancelEventArgs e)
        {
            if (combobphan.SelectedIndex != -1)
            {
                btn_chonbophan.Enabled = false;
            }
        }

        private void btn_thoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frm_Thuetnct_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (ds.HasChanges())
            {
                DialogResult = MessageBox.Show("Dữ liệu đã bị thay đổi. Bạn có muốn lưu lại không?", AccessData.Msg, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                switch (DialogResult)
                {
                    case DialogResult.Cancel:
                        e.Cancel = true;
                        break;
                    case DialogResult.No:
                        break;
                    case DialogResult.Yes:
                        btn_them.PerformClick();
                        break;
                }
            }
        }

        private void combobphan_SelectedValueChanged(object sender, EventArgs e)
        {
            if (this.ActiveControl == combobphan)
            {
                if (combobphan.SelectedIndex != -1)
                {
                    s_bophan = combobphan.SelectedValue.ToString();
                    load_rong();
                    load_data();
                }
            }
            
        }

        private void cbo_hoten_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
                SendKeys.Send("{Tab}");
        }

        private void cbo_hoten_SelectedValueChanged(object sender, EventArgs e)
        {
            if (this.ActiveControl == cbo_hoten)
                txtManv.Text = cbo_hoten.SelectedValue.ToString().Trim();
        }     
        private void dataGridView1_CurrentCellChanged(object sender, EventArgs e)
        {
            dataGridView1_CellClick(sender, null);
        }

        private void dataGridView1_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            ena_ctrl(true);
            cbo_hoten.Focus();
        }

        private void btn_boqua_Click(object sender, EventArgs e)
        {
            refesh();
        }


    }
}